package projet.volleystat;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class TeamAdapter extends ArrayAdapter<Team> {
	protected List<Team> teams;

	public TeamAdapter(Context context, int ressource, List<Team> teams) {
		super(context, ressource, teams);
		this.teams = teams;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;

		if (v == null) {
			LayoutInflater vi = LayoutInflater.from(getContext());
			v = vi.inflate(R.layout.listeitemlineteam, null);
		}

		Team team = teams.get(position);

		if (team != null) {
			TextView txtname = (TextView) v.findViewById(R.id.textteamname);
			TextView txtcountry = (TextView) v
					.findViewById(R.id.textteamcountry);

			if (txtname != null)
				txtname.setText(team.getName());
			if (txtcountry != null)
				txtcountry.setText(team.getCountry());
		}

		return v;

	}

}
